<?php
class ControllerDeployDeployMethod extends Controller {
    public function index() {

        $this->language->load("deploy/deploy_method");
        $this->data['button_default']=$this->language->get('button_default');
        $this->data['button_advanced']=$this->language->get('button_advanced');
        $quotas_pek=$this->backend->getUsedquotas($this->customer->getEmail(),'qingcloud_pek2');
        $quotas_gd=$this->backend->getUsedquotas($this->customer->getEmail(),'qingcloud_gd1');
        $quotas_ap=$this->backend->getUsedquotas($this->customer->getEmail(),'qingcloud_ap1');
        

        $quotas_limits_pek=$this->backend->getquotalimits($this->customer->getEmail(),'qingcloud_pek2');
        $quotas_limits_gd=$this->backend->getquotalimits($this->customer->getEmail(),'qingcloud_gd1');
        $quotas_limits_ap=$this->backend->getquotalimits($this->customer->getEmail(),'qingcloud_ap1');


        if(!isset($quotas_limits_ap['public_ip'])){

            $quotas_limits_ap['public_ip'] = 1;
        }
        if(!isset($quotas_limits_ap['vpc'])){
            $quotas_limits_ap['vpc'] = 1;
        }

        if(!isset($quotas_limits_ap['instance'])){
            $quotas_limits_ap['instance'] = 3;
        }


        if(!isset($quotas_ap['public_ip'])){
            $quotas_ap['public_ip'] = 0;

        }
        if(!isset($quotas_ap['vpc'])){
            $quotas_ap['vpc'] = 0;
        }

        if(!isset($quotas_ap['instance'])){
            $quotas_ap['instance'] = 0;
        }
		//get region that customer select the region from apps store


        $this->data['quotas_full']=false;
//        if(($quotas_pek['vpc']>=1||$quotas_pek['public_ip']>=1)&&$quotas_pek['instance']<3){
//            $this->data['quotas_full']=true;
//        }
//
//        if(($quotas_gd['vpc']>=1||$quotas_gd['public_ip']>=1)&&$quotas_gd['instance']<3){
//            $this->data['quotas_full']=true;
//        }
//
//        if(($quotas_ap['vpc']>=1||$quotas_ap['public_ip']>=1)&&$quotas_ap['instance']<3){
//            $this->data['quotas_full']=true;
//        }

        if(($quotas_limits_pek['vpc'] - $quotas_pek['vpc']) == 0 ||($quotas_limits_pek['public_ip'] - $quotas_pek['public_ip']) == 0 || ($quotas_limits_pek['instance'] - $quotas_pek['instance']) == 0){
            $this->data['quotas_full']=true;
        }

        if(($quotas_limits_gd['vpc'] - $quotas_gd['vpc']) == 0 ||($quotas_limits_gd['public_ip'] - $quotas_gd['public_ip']) == 0 || ($quotas_limits_gd['instance'] - $quotas_gd['instance']) == 0){
            $this->data['quotas_full']=true;
        }

        if(($quotas_limits_ap['vpc'] - $quotas_ap['vpc']) == 0 || ($quotas_limits_ap['vpc'] - $quotas_ap['public_ip']) == 0 || ($quotas_limits_ap['instance'] - $quotas_ap['instance']) == 0){
            $this->data['quotas_full']=true;
        }


    
        
        $this->data['quotas_pek_public_ip']=$quotas_pek['public_ip'];
        $this->data['quotas_pek_vpc']=$quotas_pek['vpc'];
        $this->data['quotas_pek_instance']=$quotas_pek['instance'];

        $this->data['quotas_pek_public_ip_limits']=$quotas_limits_pek['public_ip'];
        $this->data['quotas_pek_vpc_limits']=$quotas_limits_pek['vpc'];
        $this->data['quotas_pek_instance_limits']=$quotas_limits_pek['instance'];

        $this->data['quotas_gd_public_ip']=$quotas_gd['public_ip'];
        $this->data['quotas_gd_vpc']=$quotas_gd['vpc'];
        $this->data['quotas_gd_instance']=$quotas_gd['instance'];

        $this->data['quotas_gd_public_ip_limits']=$quotas_limits_gd['public_ip'];
        $this->data['quotas_gd_vpc_limits']=$quotas_limits_gd['vpc'];
        $this->data['quotas_gd_instance_limits']=$quotas_limits_gd['instance'];
        
        //ap



        
        $this->data['quotas_ap_public_ip']=$quotas_ap['public_ip'];
        $this->data['quotas_ap_vpc']=$quotas_ap['vpc'];
        $this->data['quotas_ap_instance']=$quotas_ap['instance'];



        $this->data['quotas_ap_public_ip_limits']=$quotas_limits_ap['public_ip'];
        $this->data['quotas_ap_vpc_limits']=$quotas_limits_ap['vpc'];
        $this->data['quotas_ap_instance_limits']=$quotas_limits_ap['instance'];
        //

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/deploy/deploy_method.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/deploy/deploy_method.tpl';
        } else {
            $this->template = 'default/template/deploy/deploy_method.tpl';
        }

        $this->response->setOutput($this->render());
    }

}
?>